import groovy.io.FileType

def pomFiles = []
def dir = new File('.')
dir.traverse(
        type: FileType.FILES,
        nameFilter: ~/.*_pom\.xml/
) {
    pomFiles << it
}
def jarList = [] as Set

pomFiles.each { pomFile ->
    def pomParser = new XmlParser()
    def pomRoot = pomParser.parse(pomFile)

    def dependencies = pomRoot.dependencies.dependency
    dependencies.each {
        def artifactId = it.artifactId.text()
        def version = it.version.text()

        jarList << "${artifactId}-${version}.jar"
    }
}
jarList = jarList - "ER_COMMON-1.00.00.jar"

def depFile = new File("dependency.xml")
def depMap = [:]
def depParser = new XmlParser()
def depRoot = depParser.parse(depFile)
jarList.each { jar ->
    depMap[jar] = [] as Set
    def dependencyList = depRoot.file.dependency.findAll {
        it.'@path'.contains(jar)
    }

    dependencyList.each { it ->
        def path = it.parent().'@path'
        def idx = path.indexOf("com/syniverse/")
        if (idx != -1) {
            depMap[jar] << path[idx..-1]
        } else {
            depMap[jar] << path
        }
    }
}

depMap.each { key, value ->
    println key
    value.each { v ->
        println "\t${v}"
    }
    println ""
}